function flush(id1,id2,hidden1,hidden2)
{
    $(id1).innerHTML = "Equipo 1";
    $(id2).innerHTML = "Equipo 2";
    $(hidden1).value = "";
    $(hidden2).value = "";
}

function switchTab(url, div, obj)
{
    var ullist=obj.parentNode.getElementsByTagName("li");
    for (var i=0; i<ullist.length; i++)
        ullist[i].className="";  //deselect all tabs
    obj.className="selected";  //highlight currently clicked on tab
    $(div).innerHTML="<img src=\"images/spinner.gif\" alt=\"Cargando...\" />";
    new Ajax.Updater(div,url,{evalScripts:true});
}

function newTab(obj, text, url)
{
    var ul = $(obj);
    ul.innerHTML += "<li onclick=\""+url+"\">&nbsp;&nbsp;"+text+"&nbsp;&nbsp</li>";
}

function addPoolItem(tableId,idAct,tdId)
{
    Element.hide(tdId);

    var plcs = idAct.split('_');
    var new_id = parseInt(plcs[1]);
    new_id++;

    var table = $(tableId);
    var tbody = table.getElementsByTagName('tbody').item(0);

    var newRow = document.createElement('tr');
    var inpCol = document.createElement('td');
    var imgCol = document.createElement('td');
    var addImg = document.createElement('img');
    var delImg = document.createElement('img');
    var inputP = document.createElement('input');
    var imgLnk = document.createElement('a');

    imgCol.id = "img_"+new_id;

    inputP.type = "text";
    inputP.id = "plc_"+new_id;
    inputP.name = "places[]";
    inputP.size = "20";

    addImg.src = "images/add.png";
    addImg.alt = "Nueva fila";
    addImg.title = "Nueva fila";
    addImg.className = "plus_minus";

    imgLnk.href="javascript:addPoolItem('places','plc_"+new_id+"','img_"+new_id+"')";

    delImg.src = "images/cross.png";
    delImg.alt = "Borra fila";
    delImg.title = "Borra fila";
    delImg.className = "plus_minus";
    delImg.onclick = function(){tbody.removeChild(newRow);Element.show(tdId)};

    imgLnk.appendChild(addImg);
    inpCol.appendChild(inputP);
    imgCol.appendChild(imgLnk);
    imgCol.appendChild(delImg);
    newRow.appendChild(inpCol);
    newRow.appendChild(imgCol);
    tbody.appendChild(newRow);
}

function updater(div, url)
{
    new Ajax.Updater(div,url,{evalScripts:true});
}

function updater_bottom(div, url)
{
    new Ajax.Updater(div,url,{evalScripts:true, insertion: Insertion.Bottom});
}

function send(form, div, url)
{
    var params = Form.serialize($(form));
    new Ajax.Updater(div,url,{parameters: params, evalScripts: true});
}

function sendPlayer(form, div, url)
{
    var params = Form.serialize($(form));
    var day = $('day').value;
    var month = $('month').value;
    var year = $('year').value;
    params += '&pla_date_birth='+year+'-'+month+'-'+day;
    new Ajax.Updater(div,url,{parameters: params, evalScripts: true});
}

function sendGame(form, div, url)
{
    var params = Form.serialize($(form));
    var time = $('hour').value+":"+$('min').value+":00";
    params += '&gme_time='+time;
    new Ajax.Updater(div,url,{parameters: params, evalScripts: true});
}

function deletePlace(obj, id, url)
{
    var params = "id="+id;
    new Ajax.Request(url,{parameters: params, asynchronous: false});
    $(obj).removeChild($(id));
}

function autocompleter(input, div, url, serialize, serialize_arr)
{
    new Ajax.Autocompleter(input, div, url, {minChars: 2, indicator: 'indicator1', serializeElems: serialize, serializables: serialize_arr});
}

function inplaceeditor(id, p, url)
{
    new Ajax.InPlaceEditor(p, url, {callback: function(form, value) { return 'id='+id+'&name='+p+'&value=' + value }});
}

function inplaceeditor_bottom(id, p, url)
{
    new Ajax.InPlaceEditor(p, url, {callback: function(form, value) { return 'id='+id+'&name='+p+'&value=' + value }, insertion: Insertion.Bottom});
}

function inplaceeditor_area(id, p, url, row, col)
{
    new Ajax.InPlaceEditor(p, url, {rows: row, cols: col, callback: function(form, value) { return 'id='+id+'&name='+p+'&value=' + value }});
}

function inplaceeditor_auto(id, p, url, autocompurl, div, param_name)
{
    new Ajax.InPlaceEditorAutoCompletable(p, url, {callback: function(form, value) { return 'id='+id+'&name='+p+'&value=' + value }, minChars: 2, div_ac: div, url_ac: autocompurl, paramName: param_name});
}

function inplacecollectioneditor(id, p, url, collect, def)
{
    new Ajax.InPlaceCollectionEditor(p, url, {collection: collect, callback: function(form, value) { return 'id='+id+'&name='+p+'&value=' + value}, value: def});
}

function proof_request(url)
{
    var myRequest = new Ajax.Validator(url);
    $('content_area').innerHTML = myRequest.getResult()+('').blank();
}